import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

/* Layout */
import Layout from "@/layout";

/**
 * Note: 路由配置项
 *
 * hidden: true                   // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true               // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect           // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'             // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * meta : {
    noCache: true                // 如果设置为true，则不会被 <keep-alive> 缓存(默认 false)
    title: 'title'               // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'             // 设置该路由的图标，对应路径src/assets/icons/svg
    breadcrumb: false            // 如果设置为false，则不会在breadcrumb面包屑中显示
  }
 */

const reportFormsDetailRouters = [
  {
    path: "reportForms/planCompletionMonthlyDetail",
    name: "PlanCompletionMonthlyDetail",
    component: (resolve) =>
      require([
        "@/views/reportMgmt/reportForms/planCompletionMonthlyDetail",
      ], resolve),
    meta: {
      title: "生产效率-计划完成情况明细表",
      icon: "dashboard",
      noCache: false,
      affix: false,
    },
    hidden: true,
  },
  {
    path: "reportForms/capacityUsageMonthlyDetail",
    name: "CapacityUsageMonthlyDetail",
    component: (resolve) =>
      require([
        "@/views/reportMgmt/reportForms/capacityUsageMonthlyDetail",
      ], resolve),
    meta: {
      title: "生产效率-产能利用率明细表",
      icon: "dashboard",
      noCache: false,
      affix: false,
    },
    hidden: true,
  },
  {
    path: "reportForms/failureRateMonthlyDetail",
    name: "FailureRateMonthlyDetail",
    component: (resolve) =>
      require([
        "@/views/reportMgmt/reportForms/failureRateMonthlyDetail",
      ], resolve),
    meta: {
      title: "生产效率&故障率明细表",
      icon: "dashboard",
      noCache: false,
      affix: false,
    },
    hidden: true,
  },
  {
    path: "reportForms/failureRateForMainEquipDetail",
    name: "FailureRateForMainEquipDetail",
    component: (resolve) =>
      require([
        "@/views/reportMgmt/reportForms/failureRateForMainEquipDetail",
      ], resolve),
    meta: {
      title: "核心设备故障率明细表",
      icon: "dashboard",
      noCache: false,
      affix: false,
    },
    hidden: true,
  },
  {
    path: "reportForms/energyConsumptionMonthlyDetail",
    name: "EnergyConsumptionMonthlyDetail",
    component: (resolve) =>
      require([
        "@/views/reportMgmt/reportForms/energyConsumptionMonthlyDetail",
      ], resolve),
    meta: {
      title: "能耗明细表",
      icon: "dashboard",
      noCache: false,
      affix: false,
    },
    hidden: true,
  },
  {
    path: "reportForms/packagingLossMonthlyDetail",
    name: "PackagingLossMonthlyDetail",
    component: (resolve) =>
      require([
        "@/views/reportMgmt/reportForms/packagingLossMonthlyDetail",
      ], resolve),
    meta: {
      title: "包材损耗明细表",
      icon: "dashboard",
      noCache: false,
      affix: false,
    },
    hidden: true,
  },
  {
    path: "reportForms/userEfficiencyMonthlyDetail",
    name: "UserEfficiencyMonthlyDetail",
    component: (resolve) =>
      require([
        "@/views/reportMgmt/reportForms/userEfficiencyMonthlyDetail",
      ], resolve),
    meta: {
      title: "人效明细表",
      icon: "dashboard",
      noCache: false,
      affix: false,
    },
    hidden: true,
  },
  {
    path: "reportForms/userWorkHoursDetail",
    name: "UserWorkHoursDetail",
    component: (resolve) =>
      require(["@/views/reportMgmt/reportForms/userWorkHoursDetail"], resolve),
    meta: {
      title: "人员生产工时明细表",
      icon: "dashboard",
      noCache: false,
      affix: false,
    },
    hidden: true,
  },
];

// 公共路由
export const constantRoutes = [
  {
    path: "/redirect",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "/redirect/:path(.*)",
        component: (resolve) => require(["@/views/redirect"], resolve),
      },
    ],
  },
  {
    path: "/login",
    component: (resolve) => require(["@/views/login"], resolve),
    hidden: true,
  },
  {
    path: "/404",
    component: (resolve) => require(["@/views/error/404"], resolve),
    hidden: true,
  },
  {
    path: "/401",
    component: (resolve) => require(["@/views/error/401"], resolve),
    hidden: true,
  },
  {
    path: "/",
    component: Layout,
    redirect: "/workbench",
    hidden: true,
    children:
      process.env.VUE_APP_ENV_NAME == "DEVELOPMENT"
        ? [
            {
              path: "iconView",
              name: "IconView",
              component: (resolve) => require(["@/views/iconView"], resolve),
              meta: {
                title: "系统图标",
                icon: "dashboard",
                noCache: false,
                affix: true,
              },
            },
            ...reportFormsDetailRouters,
            // {
            //   path: 'formBuild',
            //   name: 'FormBuild',
            //   component: (resolve) => require(['@/views/tool/build/index'], resolve),
            //   meta: { title: '表单配置', icon: 'dashboard', noCache: false, affix: true }
            // },
            // {
            //   path: 'form',
            //   name: 'Form',
            //   component: (resolve) => require(['@/views/form/index'], resolve),
            //   meta: { title: '单据', icon: 'dashboard', noCache: false, affix: true }
            // },
          ]
        : [...reportFormsDetailRouters],
  },
  {
    path: "/job",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "log",
        component: (resolve) => require(["@/views/monitor/job/log"], resolve),
        name: "JobLog",
        meta: { title: "调度日志" },
      },
    ],
  },
  {
    path: "/gen",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "edit/:tableId(\\d+)",
        component: (resolve) =>
          require(["@/views/tool/gen/editTable"], resolve),
        name: "GenEdit",
        meta: { title: "修改生成配置" },
      },
    ],
  },
  {
    path: "/scanPdf",
    component: (resolve) => require(["@/views/scanPdf"], resolve),
    hidden: true,
  },
];

// if (window.device == "desktop") {
//   constantRoutes.unshift(
//     // {
//     //   // 真正的路由
//     //   path: "/kanban",
//     //   component: (resolve) =>
//     //     require(["@/views/dashboard/blowIrriagtionSpinLine"], resolve),
//     //   hidden: true,
//     //   name: "kanban",
//     //   meta: { title: "产线看板", icon: "menu_systemMonitor" },
//     // },
//     // {
//     //   path: "/blowIrriagtionSpinLineDaily",
//     //   component: (resolve) =>
//     //     require(["@/views/dashboard/blowIrriagtionSpinLineDaily"], resolve),
//     //   hidden: true,
//     //   name: "BlowIrriagtionSpinLineDaily",
//     //   meta: { title: "产线日看板", icon: "menu_systemMonitor" },
//     // },
//     // {
//     //   path: "/blowIrriagtionSpinLineMonthly",
//     //   component: (resolve) =>
//     //     require(["@/views/dashboard/blowIrriagtionSpinLineMonthly"], resolve),
//     //   hidden: true,
//     //   name: "BlowIrriagtionSpinLineMonthly",
//     //   meta: { title: "产线月看板", icon: "menu_systemMonitor" },
//     // },
//     // {
//     //   path: "/injectionWorkshop",
//     //   component: (resolve) =>
//     //     require(["@/views/dashboard/injectionWorkshop"], resolve),
//     //   hidden: true,
//     //   name: "InjectionWorkshop",
//     //   meta: { title: "车间看板", icon: "menu_systemMonitor" },
//     // },
//     {
//       path: "/dashboardMgmt", // 显示在菜单
//       component: Layout,
//       hidden: false,
//       meta: { title: "看板管理", icon: "menu_systemMonitor" },
//       children: [
//         {
//           path: "/blowIrriagtionSpinLineDaily",
//           component: (resolve) =>
//             require(["@/views/dashboard/blowIrriagtionSpinLineDaily"], resolve),
//           hidden: false,
//           name: "BlowIrriagtionSpinLineDaily",
//           meta: {
//             title: "产线日看板",
//             icon: "menu_systemMonitor",
//             noCache: false,
//           },
//         },
//         {
//           path: "/blowIrriagtionSpinLineMonthly",
//           component: (resolve) =>
//             require([
//               "@/views/dashboard/blowIrriagtionSpinLineMonthly",
//             ], resolve),
//           hidden: false,
//           name: "BlowIrriagtionSpinLineMonthly",
//           meta: {
//             title: "产线月看板",
//             icon: "menu_systemMonitor",
//             noCache: false,
//           },
//         },
//         {
//           path: "/injectionWorkshop",
//           component: (resolve) =>
//             require(["@/views/dashboard/injectionWorkshop"], resolve),
//           hidden: false,
//           name: "InjectionWorkshop",
//           meta: {
//             title: "车间看板",
//             icon: "menu_systemMonitor",
//             noCache: false,
//           },
//         },
//       ],
//     }
//   );
// }

export default new Router({
  // mode: 'history', // 去掉url中的#
  mode: "hash",
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes,
});
